﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;

namespace WindowsFormsApp3
{
    class DBhelper
    {
        public  static DataTable GetDataTable(string sql)
        {
            string connStr = "server=.;database =school;uid=sa;pwd=20000624...";
            SqlConnection conn = new SqlConnection(connStr);

            conn.Open();
       
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, conn);
            DataTable da = new DataTable();

            dataAdapter.Fill(da);

            return da;

        }
        public static int AddOrUpdateOrDelect(string sql)
        {
            string connStr = "server=.;database =school;uid=sa;pwd=20000624...";
            SqlConnection conn = new SqlConnection(connStr);
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql,conn);
            
            return cmd.ExecuteNonQuery();

            
        }
    }
}
